<?php
	####################################################
	# library import and object instance.              #
	####################################################
	# 커먼 인클루드
	include_once( '../common.php' );

	####################################################
	# request data($_POST AND $_GET FROM $_REQUEST)    #
	####################################################
	# REQUEST(get and post variables)
	//$req = Request::clean_request($_REQUEST, FALSE);

	# GET(url variables)

	# POST(form variables)

	# Validation(special case validate)

	####################################################
	# implementation                                   #
	####################################################
	$sec->individual_access();
	$sec->run_cookie_check();

	# 모드를 구하고 각 값을 가져온다.
	$mode = $sec->get_ipfilltering_mode();
	$type = $sec->get_ipfilltering_type();
	foreach($mode as $key=>$val){
		foreach($type as $tkey=>$tval) {
			$list[$tval][$val] = $sec->get_ipfilltering_ip_in_type_and_mode($tval, $val);
		}
	}
	//Nlog::puts($list);

?>
<?php
	# HTML START
	echo $html->custom_header(TITLE);
	echo $tplt->page_construct_javascript();
	echo $html->custom_js("{$JS}common.js");
	echo $html->custom_css("{$CSS}common.css");
	echo $html->custom_body();
?>
	<?php $tplt->app_head($NAVI)?>
	<?php $tplt->tiles_admin_sidebar($NAVI)?>
	<?php $tplt->tiles_admin_contents($pkname, $pname, $pdesc)?>


		<?php foreach($type as $types):?>
			<?php if($types == 'deny'):?>
				<h4>ip filltering > 접근 불가(deny - 입력된 IP의 컴퓨터는 접근할 수 없습니다. deny가 우선함.)</h4>
			<?php endif;?>
			<?php if($types == 'allow'):?>
				<h4>ip filltering > 접근 허가(allow - 입력된 IP의 컴퓨터만 접근할 수 있습니다.)</h4>
			<?php endif;?>
			<?php echo NForm::open(NULL, FALSE, $types);?>
				<?php echo NForm::mode('delete')?>
				<table class="tbl" border="0" cellpadding="3" cellspacing="0">
					<colgroup>
						<col width="40" />
						<col width="100" />
						<col width="*" />
					</colgroup>
					<tr>
						<th>번호</th>
						<th>모드</th>
						<th>ip</th>
					</tr>
					<?php foreach($mode as $key=>$modes):?>
						<tr>
							<td class="th">
								<?=$key+1?>
							</td>
							<td>
								<?=$modes?>
							</td>
							<td>
							<?php if(array_key_exists($modes, $list[$types])): ?>
								<table class="tbl" width="100%" border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;">
									<colgroup>
										<col width="40" />
										<col width="80" />
										<col width="*" />
									</colgroup>
									<tr>
										<th><input type="checkbox" id="chkctr1<?=$modes?><?=$types?>" onclick="CheckboxControl.toggle_check_all('#chkctr1<?=$modes?><?=$types?>','.chk1<?=$modes?><?=$types?>');" /></th>
										<th>uid</th>
										<th>대상 ip</th>
									</tr>
									<?php if( (count($list[$types][$modes]) > 0) && is_array($list[$types][$modes])) foreach($list[$types][$modes] as $key=>$val):?>
										<tr>
											<td>
												<input type="checkbox" name="map[<?=$val['uid']?>][uid]" id="chk1_<?=$val['uid']?>" class="chk1<?=$modes?><?=$types?>" value="<?=$val['uid']?>" />
											</td>
											<td>
												<?=$val['uid']?>
											</td>
											<td>
												<?=$val['ip']?>
											</td>
										</tr>
									<?php endforeach;?>
								</table>
							</td>
							<?php endif; ?>
						</tr>
					<?php endforeach;?>
				</table>
			<?php echo NForm::close();?>
			<div class="tblt">
				체크된 대상ip를 : <span class="cbtn_s" onclick="$('#formx_<?=$types?>').submit();">삭제</span>&nbsp;
			</div>
			<br />
		<?php endforeach;?>



		<h4>아이피 필터링 추가 (000.000.+ 도 입력 가능 합니다.)</h4>
		<?php echo NForm::open(NULL, FALSE, "set");?>
			<?php echo NForm::mode('set')?>
			<table class="tbl" border="0" cellpadding="0" cellspacing="0">
				<colgroup>
					<col width="*" />
					<col width="*" />
					<col width="*" />
					<col width="80" />
				</colgroup>
				<tr>
					<th>타입</th>
					<th>모드</th>
					<th>아이피</th>
					<th>명령</th>
				</tr>
				<tr>
					<td>
						<select name="map[type]" class="wmatch">
							<?php foreach($type as $key=>$val):?>
								<option value="<?=$val?>">
									<?=$val?>
								</option>
							<?php endforeach;?>
						</select>
					</td>
					<td>
						<select name="map[mode]" class="wmatch">
							<?php foreach($mode as $key=>$val):?>
								<option value="<?=$val?>">
									<?=$val?>
								</option>
							<?php endforeach;?>
						</select>
					</td>
					<td>
						<input type="text" name="map[ip]" maxlength="100" value="" class="inp wmatch" />
					</td>
					<td>
						<span class="cbtn_s" onclick="$('#formx_set').submit();">등록</span>
					</td>
			</table>
		<?php echo NForm::close();?>
<?php
	# HTML END
	echo $tplt->tiles_admin_footer();
	echo $tplt->page_destruct_javascript();
	include_once( '../endproc.php' );
	echo $html->html_footer();
?>